Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow lazier configuration of jdks #19

Merged
merged 15 commits into from
May 12, 2022

Conversation

CRogers
Copy link
Contributor

@CRogers CRogers commented May 5, 2022

Before this PR

When configuring an internal Gradle plugin to configure this plugin I ran into a problem - I couldn't work out which JDKs I had without doing an expensive network task - basically what @carterkozak warning me about in the baseline code.

After this PR

==COMMIT_MSG==
Allow lazy configuration of JDKs
==COMMIT_MSG==

Extra methods allow me to provide all the jdk configuration lazily when it is requested.

Possible downsides?

@CRogers CRogers requested a review from carterkozak May 5, 2022 13:29
@changelog-app
Copy link

changelog-app bot commented May 5, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Allow lazy configuration of JDKs

Check the box to generate changelog(s)

  • Generate changelog entry

import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;

final class DelayedConfigurableMap<K, V> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use some of the built in NamedDomainObjectCollection/MapProperty but they really did not seem to do exactly what I wanted - so I build my own thing here.

final class DelayedConfigurableMap<K, V> {
private final ProviderFactory providerFactory;
private final Supplier<V> valueFactory;
private final List<Provider<Map<K, Action<V>>>> configurations = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>>> looks a lot like a merge conflict!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how you tell it's good code

import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;

final class DelayedConfigurableMap<K, V> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would it look like to abandon the map concept entirely, in favor of something shaped more like a function? I suspect this isn't the only place the map property may bite us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should probably do that, started it here: palantir/gradle-baseline#2263

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this PR to show what it would look like.

@CRogers CRogers merged commit 5904f1f into develop May 12, 2022
@svc-autorelease
Copy link
Collaborator

Released 0.4.0

@CRogers CRogers deleted the callumr/allow-lazier-configuration branch May 12, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants